#include"Stack.h"

Stack::Stack(int n)
{
	_a = (int*)malloc(sizeof(int)*n);
	_top = 0;
	_capacity = n;
}

Stack::~Stack()
{
	cout << "~Stack()" << endl;
	free(_a);
	_a = nullptr;
	_top = 0;
	_capacity = 0;
}

//void Stack::Init()
//{
//	_a = nullptr;
//	_top = 0;
//	_capacity = 0;
//}

//void Destroy()
//{
//	//...
//}

void Stack::Push(int x)
{
	// ...
	_a[_top++] = x;
}

bool Stack::Empty()
{
	return _top == 0;
}

void Stack::Pop()
{
	--_top;
}

int Stack::Top()
{
	return _a[_top - 1];
}

//void Queue::Push(int x)
//{
//
//}


